<%@page import="form.Valider"%>
<%@page import="bean.User"  %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<jsp:useBean id="user" scope="request" class="bean.User" />

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<% 
String sessionUser = (String) session.getAttribute("username");
User med;
if (sessionUser == null){
	response.sendRedirect("../modele/modele.jsp");
	return ;
}else{
	med = User.getUser(sessionUser);
}
%> 
<title>Page d'administration</title>
</head>
<body>
<%

if (request.getParameter("submit") != null) {
	boolean res = false;
	if (request.getParameter("login") != null){
		res = true;
		user.setLogin(request.getParameter("login"));
	}
	if (request.getParameter("prenom") != null){
		res = true;
		user.setPrenom(request.getParameter("prenom"));
	}
	if (request.getParameter("adresse") != null){
		res = true;
		user.setAdresse(request.getParameter("adresse"));
	}
	if (request.getParameter("codePostal") != null){
		res = true;
		user.setCodePostal(Integer.parseInt(request.getParameter("codePostal")));
	}
	if (request.getParameter("ville") != null){
		res = true;
		user.setVille(request.getParameter("ville"));
	}
	if (request.getParameter("telephone") != null){
		res = true;
		user.setTelephone(Integer.parseInt(request.getParameter("numTel")));
	}
	if (res){
		User.modifierUser(user);
		out.println("<script type=\"text/javascript\">");
		out.println("	alert (\"Informations modifiees\");");
		out.println("	window.location.replace(\"../modele/modele.jsp\");");
		out.println("</script>");
	}
}
%>
<%@ include file="../commun_page_swmenufree/swmenufree.jsp" %>
<jsp:include page="${pageConfig.contenu}" />

<h3>Modification des informations du medecin</h3>

<form method="post">
	<table>
	<tr>
		<td>Nom : </td>
		<td><input type="text" name="login" value="<%= med.getLogin() %>" size=55 maxlength=255 /> * </td>
		<td>${patient.err.nom}</td>
	</tr>
	<tr>
		<td>Prenom : </td>
		<td><input type="text" name="prenom" value="<%= med.getPrenom() %>" size=55 maxlength=255 /> *</td>
		<td>${patient.err.prenom}</td>
	</tr>
	<tr>
		<td>Adresse : </td>
		<td><input type="text" name="adresse" value="<%= med.getAdresse() %>" size=55 maxlength=255/> *</td>
		<td>${patient.err.adresse}</td>
	</tr>
	<tr>
		<td>Code Postal : </td>
		<td><input type="text" name="codePostal" value="<%= med.getCodePostal() %>" size=5 maxlength=5/> *</td>
		<td>${patient.err.codePostal}</td>
	</tr>
	<tr>
		<td>Ville : </td>
		<td><input type="text" name="ville" value="<%= med.getVille() %>" size=55 maxlength=255/> *</td>
		<td>${patient.err.ville}</td>
	</tr>
	<tr>
		<td>Telephone : </td>
		<td><input type="text" name="numTel" value="<%= med.getTelephone() %>" size=10 maxlength=10/> *</td>
		<td>${patient.err.numTel}</td>
	</tr>
	<tr>
		<td> <h4><font color="red">*: champs obligatoires</font></h4></td>
		<td></td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td><input type="submit" name="submit" value="Valider les modifications"/></td>
		<td></td>
	</tr>
	
	</table>
</form>

</body>
</html>